/*
  VoIP Wholesale 1.0
  ------------------
  Document   : module_functions.js
  Created on : Sep 14, 2011, 4:16:45 PM
  Author     : Milos Jovanovic <miloscode@gmail.com>
  Description:

 */
function save_new_route()
{
        ajaxURL = AJAX_URL + '/add_new_route/';
            
        //alert(ajaxURL);

	$.ajax({
			type: "POST",
			url: ajaxURL,
			data: $('#new-route').serialize(),
			async: true,
			success: function(response){
                        
                        var parsed = response.split('|');
                        
                        var html = '';
                        
                        if(parsed[0] == "true")
                            {
                                    html += "<p><span class='highlight-icon ui-icon ui-icon-info'></span>";                                
                                    html += parsed[1] +"</p>";
                                
                                    $('#response')
                                        .addClass('ui-state-highlight ui-corner-all')
                                        .html(html);                                
                            }
                        else if(parsed[0] == "empty_route_name")
                            {
                                    html += "<p><span class='highlight-icon ui-icon ui-icon-alert'></span>";                                
                                    html += parsed[1] +"</p>";
                                
                                    $('#response')
                                        .addClass('ui-state-error ui-corner-all')
                                        .html(html);       
                                        
                                    $('#route-name')
                                        .addClass('ui-state-error');
                            }

                        else if(parsed[0] == "empty_dialcodes")
                            {
                                    html += "<p><span class='highlight-icon ui-icon ui-icon-alert'></span>";                                
                                    html += parsed[1] +"</p>";
                                
                                    $('#response')
                                        .addClass('ui-state-error ui-corner-all')
                                        .html(html);       
                                        
                                    $('#dialling-codes')
                                        .addClass('ui-state-error');
                            }
                         else
                             {
                                 alert(response);
                             }


			}
		  });

}
